<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$return['ischecklogin']=model('core/core')->checklogin('','',true);
	$_SESSION['memberid']=$this->model('member')->checkmember();
	$_SESSION['logout_forward']='jy_aihire/home';
	$member=pdo_get('jy_aihire_member',array('id'=>$_SESSION['memberid'],'uniacid'=>$_SESSION['uniacid']));
	if(!$member){
		exi('找不到会员信息！','error');
	}
	$return['member']=$member;
	$return['list']=pdo_getall('jy_aihire_member_bank',array('memberid'=>$_SESSION['memberid'],'uniacid'=>$_SESSION['uniacid']));
	set_html('title','我的银行卡');
	exi($return);
}
if($_RQ['op']=='edit'){
	$member=pdo_get('jy_aihire_member',array('id'=>$_SESSION['memberid'],'uniacid'=>$_SESSION['uniacid']));
	if(!$member){
		exi('找不到会员信息！','error');
	}
	$return['member']=$member;
	if($_RQ['id']){
		$return['post']=pdo_get('jy_aihire_member_bank',array('id'=>$_RQ['id'],'uniacid'=>$_SESSION['uniacid']));
	}else{
		$return['post']=array('mobile'=>$member['mobile']);
	}
	set_html('title','我的银行卡');
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['banktitle'] || !$postdata['bankno'] || !$postdata['mobile']){
		exi('银行名称，银行卡号，手机号必填！','error');
	}
	$id=$postdata['id'];
	$update=array(
		'banktitle'=>trim($postdata['banktitle']),
		'bankno'=>trim($postdata['bankno']),
		'mobile'=>trim($postdata['mobile']),
		'kaidi'=>trim($postdata['kaidi']),
		'kaihang'=>trim($postdata['kaihang']),
		'hanghao'=>trim($postdata['hanghao']),
		'uptime'=>time(),
	);
	if($id){
		pdo_update('jy_aihire_member_bank',$update,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$update['uniacid']=$_SESSION['uniacid'];
		$update['mid']=$_SESSION['uid'];
		$update['memberid']=$_SESSION['memberid'];
		$update['createtime']=time();
		pdo_insert('jy_aihire_member_bank',$update);
	}
	exi('设置成功！','','goback');
}